<!DOCTYPE html>
<html lang="zh-cn">
    <head>
        <meta charset="UTF-8"/>
        <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0" />
        <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
        <title>多张图片垂直居中</title>
        <style type="text/css">
            .imgWrap li {
                float: left;
                border: solid 1px #666;
                margin: 10px 10px 0 0;
                list-style: none;
                border-collapse: collapse; 
            }
            .imgWrap a {
                background: #ffa url(images/gridBg.gif) repeat center;
                width: 219px;
                height: 219px;
                display: table-cell;/*图片容器以表格的单元格形式显示*/
                text-align: center; /* 实现水平居中 */
                vertical-align: middle; /*实现垂直居中*/                  
            }
            .imgWrap a:hover {
                background-color: #dfd;
            }
            .imgWrap img {
                border: solid 1px #66f;
                vertical-align: middle; /*图片垂直居中*/
            }
            </style>
            <!--下面是解决IE6-7的正常显示的代码-->
            <!--[if lt IE 8]>
                <style type="text/css">
                .imgWrap a {
                    display: block;
                }
                .imgWrap span {
                    display: inline-block;
                    vertical-align: middle;
                    height: 100%;
                }
                .imgWrap {
                    _height: 0;
                    zoom: 1;
                }
                </style>
            <![endif]-->
    </head>
    <body>
        <ul class="imgWrap clearfix">
            <li><a href="#" class="imgBox"><span></span><img src="images/img1.jpg" alt="" /></a></li>
            <li><a href="#" class="imgBox"><span></span><img src="images/img2.jpg" alt="" /></a></li>
            <li><a href="#" class="imgBox"><span></span><img src="images/img3.jpg" alt="" /></a></li>
            <li><a href="#" class="imgBox"><span></span><img src="images/img4.jpg" alt="" /></a></li>
        </ul>
        <script>
            
        </script>
    </body>
</html>